//
//  LCustomCell.m
//  LAutoHeightDemo
//
//  Created by 李明明 on 16/7/18.
//  Copyright © 2016年 李明明. All rights reserved.
//

#import "LCustomCell.h"
#import <Masonry/Masonry.h>
@interface LCustomCell ()
@property (nonatomic, weak) UILabel *lab;
@property (nonatomic, weak) UILabel *topLab;
@end

@implementation LCustomCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
}

- (void)loadInfo:(id)info
{
    self.lab.text = info;
}

- (UILabel *)lab
{
    if (!_lab) {
        UILabel *lab = [[UILabel alloc] init];
        lab.translatesAutoresizingMaskIntoConstraints = YES;
        lab.numberOfLines = 0;
        [self addSubview:lab];
        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.topLab.mas_bottom).with.offset(0);
            make.left.equalTo(self.mas_left).with.offset(0);
            make.bottom.equalTo(self.mas_bottom).with.offset(0);
            make.right.equalTo(self.mas_right).with.offset(0);
        }];
        
        _lab = lab;
    }
    return _lab;
}

- (UILabel *)topLab
{
    if (!_topLab) {
        
        UILabel *topLab = [[UILabel alloc] init];
        topLab.backgroundColor = [UIColor yellowColor];
        topLab.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:topLab];
        topLab.text = @"固定高度的lab";
        [topLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.mas_top).with.offset(0);
            make.left.equalTo(self.mas_left).with.offset(0);
            make.height.equalTo(@(20));
            make.right.equalTo(self.mas_right).with.offset(0);
        }];
        _topLab = topLab;
    }
    return _topLab;
    
    
}

@end
